package chapt08.tunnel;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.media.opengl.awt.GLCanvas;

public class TunnelKeyListener implements KeyListener
{
	GLCanvas glcanvas;
	
	TunnelKeyListener(GLCanvas glcanvas)
	{
		this.glcanvas = glcanvas;
	}
	
	@Override
	public void keyPressed(KeyEvent e)
	{
		int key = e.getKeyCode();
		
		if(key == KeyEvent.VK_UP)
			Tunnel.zPos += 1.0f;
		
		else if(key == KeyEvent.VK_DOWN)
			Tunnel.zPos -= 1.0f;

		// Refresh the Window
		glcanvas.display();
	}
	
	@Override
	public void keyReleased(KeyEvent e)
	{
		
	}
	
	@Override
	public void keyTyped(KeyEvent e)
	{
		
	}
}
